package com.hedl.practice.diyJava.array;

import java.util.Arrays;

public class JavaAndArray02 {
    public static void main(String[] args) {

        int[][] ns = {{1,2,3,4},
                {5,6,7,8},
                {9,10,11,12}};

        //System.out.println(ns.length);
        //System.out.println(ns[2][0]);

        //打印
        /*for (int[] arr:ns){
            for (int n:arr){
                System.out.print(n);
                System.out.print(",");
            }
            System.out.println();
        }*/


        //使用java提供的方法，打印
        //System.out.println(Arrays.deepToString(ns));

        //表示一组学生的各科成绩，请计算所有学生的平均分：
        int[][] scores = {{82,90,91},
                {68,72,64},
                {95,91,89},
                {67,52,60},
                {79,81,85}};
        // 求和
        int sum = 0;
        for (int i = 0;i < scores.length;i++){
            for (int j = 0;j < scores[i].length;j++){
                sum += scores[i][j];
            }
        }

        //求平均分
        double average = sum * 1.0 / (scores.length * scores[0].length);

        System.out.println("总分："+sum);
        System.out.println("平均分："+average);

    }
}
